LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
USE IEEE.std_logic_unsigned.ALL;
USE IEEE.std_logic_arith.ALL;

entity cont10000 is
port(
	rst : in std_logic;
	ck: in std_logic;
	e: in std_logic;
	q3 : out std_logic_vector(3 downto 0);
	q2 : out std_logic_vector(3 downto 0);
	q1 : out std_logic_vector(3 downto 0);
	q0 : out std_logic_vector(3 downto 0)
	);
end;

architecture aCont10000 of cont10000 is
  component ContadorBCD is
  port(
	rst : in std_logic;
	ck: in std_logic;
	ei: in std_logic;
	q0 : out std_logic;
	q1 : out std_logic;
	q2 : out std_logic;
	q3 : out std_logic;
	eo : out std_logic);
  end component;  
  signal e,e2s,e3s:std_logic;
  signal e1,e2,e3:std_logic;
begin
  contador0: ContadorBCD port map (rst,ck,e,q0(0),q0(1),q0(2),q0(3),e1);
  contador1: ContadorBCD port map (rst,ck,e1,q1(0),q1(1),q1(2),q1(3),e2);
  contador2: ContadorBCD port map (rst,ck,e2,q2(0),q2(1),q2(2),q2(3),e3);
  contador3: ContadorBCD port map (rst,ck,e3,q3(0),q3(1),q3(2),q3(3),open);
end;

LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
USE IEEE.std_logic_unsigned.ALL;
USE IEEE.std_logic_arith.ALL;

entity testContador10000 is
end;

architecture t1 of testContador10000 is
  component cont10000 is
port(
	rst : in std_logic;
	ck: in std_logic;
	q3 : out std_logic_vector(3 downto 0);
	q2 : out std_logic_vector(3 downto 0);
	q1 : out std_logic_vector(3 downto 0);
	q0 : out std_logic_vector(3 downto 0)
	);
	
  end component;
  signal clr_s : std_logic := '1';
  signal ck_s : std_logic := '0';
  signal e_s : std_logic := '1';
  signal q_1: std_logic_vector(3 downto 0);
  signal q_2: std_logic_vector(3 downto 0);
  signal q_3: std_logic_vector(3 downto 0);
  signal q_4: std_logic_vector(3 downto 0);
  
begin
clr_s <= '0' after 50 ns;
ck_s <= not ck_s after 10 ns;
cont: cont10000 port map (clr_s , ck_s , q_4 , q_3, q_2, q_1); 
  process (ck)
    variable contadorGeneradorDeEnable : natural := 0;
  begin
    if ck'event and ck='1' then
        contadorGeneradorDeEnable := contadorGeneradorDeEnable+1 ;
        if contadorGeneradorDeEnable=5 then 
          contadorGeneradorDeEnable:= 0;
          e<='1';
        else
          e<='0';  
        end if;
    end if;
  end process; 
    
end;

